When I write the following code I get garbage for an output. It is just a simple program to find prime numbers. It works when the first for loops range only goes up to 1000 but once the range becomes large the program fail's to output meaningful data
output = open("output.dat", 'w')
for i in range(2, 10000):
prime = 1
for j in r...
I want to take the control of the window
for exmple i want to force to external app to start minimized
I mean when i enter this command
myapp Firefox
Firefox starts but minimized
firefox is not important I mean i want to do it with any gui application
If yes
can any body show me the way?
...
I had never noticed the __path__ attribute that gets defined on some of my packages before today. According to the documentation:
Packages support one more special
attribute, __path__. This is
initialized to be a list containing
the name of the directory holding the
package’s __init__.py before the code
in that file is exe...
Hi,
The background of my question is associated with Tesseract, the free OCR engine (1985-1995 by HP, now hosting in Google). It specifically requires an input file and an output file; the argument only takes filename (not stream / binary string), so in order to use the wrapper API such as pytesser and / or python-tesser.py, the OCR tem...
I want to plot some data. The first column contains the x-data. But matplotlib doesnt plot this. Where is my mistake?
#fresnel formula
import numpy as np
from numpy import cos
from scipy import *
from pylab import plot, show, ylim, yticks
from matplotlib import *
from pprint import pprint
n1 = 1.0
n2 = 1.5
#alpha, beta, intensity
dat...
How would I match a space separated list of words followed by whitespace and some optional numbers?
I have this:
>>> import re
>>> m = re.match('(?P<words>(\S+\s+)+)(?P<num>\d+)?\r\n', 'Foo Bar 12345\r\n')
>>> m.groupdict()
{'num': '12345', 'words': 'Foo Bar '}
I'd like the words group to not include the last whitespace(s) but I can...
I'm trying to use regular expression to extract the comments in the heading of a file.
For example, the source code may look like:
//This is an example file.
//Please help me.
#include "test.h"
int main() //main function
{
...
}
What I want to extract from the code are the first two lines, i.e.
//This is an example file.
//Please...
I'm looking for a good way to store and use hierarchical (parent/child) data in Django. I've been using django-mptt, but it seems entirely incompatible with my brain - I end up with non-obvious bugs in non-obvious places, mostly when moving things around in the tree: I end up with inconsistent state, where a node and its parent will disa...
I'd like to have a Python program start listening on port 80, but after that execute without root permissions. Is there a way to drop root or to get port 80 without it?
...
Currently, I have a parser with multiple classes that work together.
For Instance: TreeParser creates multiple Product and Reactant modules which in turn create multiple Element classes. The TreeParser is called by a render method within the same module, which is called from the importer.
Finally, if the package has dependencies (such ...
Hello!
The following code does not work. It seems that the R warning message raises a python error.
# enable use of python objects in rpy2
import rpy2.robjects.numpy2ri
import numpy as np
from rpy2.robjects import r
# create an example array
a = np.array([[5,2,5],[3,7,8]])
# this line leads to a warning message, which in turn raises ...
I have a file that was written with the following Delphi declaration ...
Type
Tfulldata = Record
dpoints, dloops : integer;
dtime, bT, sT, hI, LI : real;
tm : real;
data : array[1..armax] Of Real;
End;
...
Var:
fh: File Of Tfulldata;
I want to analyse the data in the files (many MB in size) using Python if poss...
Let's say i go to myblog.com/post/12. The /post handler is already defined, but how can i get the parameter being passed? 12 in this case is the post_id.
I'm using the Python SDK.
...
I am new to python. I have to make a program for a project that takes a PDB format file as input and returns a list of all the intra-chain and inter-chain charge pairs and their energies (using coulomb’s law assuming a dielectric constant of () of 40.0). For simplicity, the charged residues for this program are just Arg (CZ), Lys (NZ)...
I'm searching for a string in a website and checking to see if the location of this string is in the expected location. I know the string starts at the 182nd character, and if I print temp it will even tell me that it is 182, however, the if statement says 182 is not 182.
Some code
f = urllib.urlopen(link)
#store page contents in 's...
Does anybody know any module in Python that computes the best bipartite matching?
I have tried the following two:
munkres
hungarian
However, in my case, I have to deal with non-complete graph (i.e., there might not be an edge between two nodes), and therefore, there might not be a match if the node has no edge. The above two packag...
I am trying to learn python and couldn't figure out how to translate the following perl script to python:
#!/usr/bin/perl -w
use open qw(:std :utf8);
while(<>) {
s/\x{00E4}/ae/;
s/\x{00F6}/oe/;
s/\x{00FC}/ue/;
print;
}
The script just changes unicode umlauts to alternative ascii output. (So the complete ...
Can regular expressions be used to perform arithmetic? Such as find all numbers in a file and multiply them by a scalar value.
...
I am looking for an API (preferably in python) that could be used to analyze complex networks. Basically I want to find things like:
Average shortest path,
Degree distribution
Giant Component
local clustering coefficient, global clustering coefficient etc..
Thanks
...
Hey guys, -- I just parsed a big file and I created a list containing 42.000 strings/words. I want to query [against this list] to check if a given word/string belongs to it. So my question is: What is the most efficient way for such a lookup? A first approach is to sort the list [list.sort()] and then just use the >> if word in list: ...