Re: Python.h
[EMAIL PROTECTED] wrote: > I am running python to c converter application. It throws an > error saying python.h file not found. >Can somebody plz suggest how to resolve this problem. you need the python build files. if you're using Linux, look for something named python-dev or python-devel in your favourite package repository. -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: unix newbie questions
Fredrik Lundh wrote: >> *24. Display recent 10 java files, (with *.java extension) , in >> descending order by time, latest to oldest time. (1) * > > >>> files = sorted(glob.glob("*.py"), key=os.path.getmtime)[-10:] > >>> files.reverse() (to display the files, use print) -- http://mail.python.org/mailman/listinfo/python-list
Writing to a certain line?
I was wondering if there was a way to take a txt file and, while keeping most of it, replace only one line. See, I'd have a file like: Tommy 555 Bob 62 Joe 529 And I'd want to set it to be: Tommy 555 Bob 66 Joe 529 Is there any easy way to do this? -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: unix newbie questions
Carlos Lopez wrote: > Please help i am losing my mind ... UNIX Newbee > > *23. How do you add a line to the end of an existing file "myfile" with > date stamp. (1) * >>> f = open("myfile", "a+") >>> f.write(datestamp) >>> f.close() > *24. Display recent 10 java files, (with *.java extension) , in > descending order by time, latest to oldest time. (1) * >>> files = sorted(glob.glob("*.py"), key=os.path.getmtime)[-10:] >>> files.reverse() > *25. How do you set only read permissions to user, group and others in > octal mode for a file "myfile.txt" ? (2) >>> os.chmod("myfile.txt", 0444) # note the leading zero > *26. You observed that some of your group members are fiddling with your > file "myfile" and you wanted to remove the read permission to your > group. How do you do? (1) >>> os.chmod("myfile.txt", 0404) > *28. Here is another long listing of a file. (1)* > -rw-r- 1 Y435678 odms 20 Sep 02 17:03 file.txt. *** > > *What are the owner permissions? * >>> s = os.stat("urllib.py").st_mode >>> if s & stat.S_IREAD: print "READ" >>> if s & stat.S_IWRITE: print "WRITE" >>> if s & stat.S_IEXEC: print "EXEC" > *29. The file “users_data” has the following contents : (1) > Tom Smith 7.00 15 105.00 > Rob Sheryl 8.00 20 160.00 > Ken Bradman 7.00 13 91.00 > Peter Smith 6.00 15 90.00 > Dennis Smith 8.00 13 104.00 > Tom Dave9.00 12 108.00 * > > *How do you sort the above file and redirect the output to another file > called “sortedusers” * >>> out = open("sortedusers", "w") >>> out.writelines(sorted(open("users_data"))) > *20. What is the command to list files in a directory : (2) >>> os.listdir(directory) or, if you want full path names and glob-style filtering: >>> glob.glob(os.path.join(directory, "*")) -- http://mail.python.org/mailman/listinfo/python-list
Python.h
Hi, I am running python to c converter application. It throws an error saying python.h file not found. Can somebody plz suggest how to resolve this problem. Regards, Praveen Kumar -- http://mail.python.org/mailman/listinfo/python-list
Re: Again, Downloading and Displaying an Image from the Internet in Tkinter
Le Mardi 06 Juin 2006 03:08, Dustan a écrit : > > I should probably also mention, the only reason I downloaded the image > to a file was because I don't know of any other way to do it. I feel no > need to save the image to my hard drive. using PIL, there is something like this (untested) : (assuming you have put your image data in a file-like object, ie. a StringIO, named self._dled_img) Label(self.frame, image=TkImage(Image.open(self._dled_img))) -- _ Maric Michaud _ Aristote - www.aristote.info 3 place des tapis 69004 Lyon Tel: +33 426 880 097 -- http://mail.python.org/mailman/listinfo/python-list
Re: C# equivalent to range()
Fuzzyman wrote: > Well, this is true. Doesn't make it a *good* thing of course... :-) on the other hand, the rules for what works and doesn't on public forums have been finely tuned for many years. that's why "the rules don't apply to me" people like Lee, "Neuruss", and others get the kind of pushback they're getting. and frankly, their approach doesn't work in real life, so what makes you think it would work on the internet? -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading from a file and converting it into a list of lines
Really sorry for that indentation thing :) I tried out the code you have given, and also the one sreeram had written. In all of these,i get the same error of this type: Error i get in Sreeram's code is: n1,_,n2,_ = line.split(',') ValueError: need more than 1 value to unpack And error i get in your code is: for n1, a1, n2, a2 in reader: ValueError: need more than 0 values to unpack Any ideas why this is happening? Thanks a lot, girish -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add few pictures into one
> > All that I want is this: > > I download ( via Python) some pictures from internet and I want to add > > all these pictures into one =one file/ > > So far, I managed to download pictures but I do not know how to add i > > them nto one file. > > How can I do that? > > Thank you for reply and help > > L. > > > Zip file? Image file? "Add all these pictures into one file" isn't (fro > me) a sufficient specification. I want to to do that as easy as possible. I think the easest way could be add( append) an image to another into an image file so that I can use an image browser and see all pictures in one file. Is that possible? Thank you for reply L. -- http://mail.python.org/mailman/listinfo/python-list
Re: Concatenating dictionary values and keys, and further operations
Girish Sahani wrote: > Gerard Flanagan wrote: >> Girish Sahani wrote: >> > I wrote the following code to concatenate every 2 keys of a dictionary >> and >> > their corresponding values. >> > e.g if i have tiDict1 = tiDict1 = {'a':[1,2],'b':[3,4,5]} i should get >> > tiDict2={'ab':[1,2][3,4,5]} and similarly for dicts with larger no. of >> > features. >> > Now i want to check each pair to see if they are connected...element >> of >> > this pair will be one from the first list and one from the >> seconde.g >> > for 'ab' i want to check if 1 and 3 are connected,then 1 and 4,then 1 >> and >> > 5,then 2 and 3,then 2 and 4,then 2 and 5. >> > The information of this connected thing is in a text file as follows: >> > 1,'a',2,'b' >> > 3,'a',5,'a' >> > 3,'a',6,'a' >> > 3,'a',7,'b' >> > 8,'a',7,'b' >> > . >> > . >> > This means 1(type 'a') and 2(type 'b') are connected,3 and 5 are >> connected >> > and so on. >> > I am not able to figure out how to do this.Any pointers would be >> helpful >> >> >> Girish >> >> It seems you want the Cartesian product of every pair of lists in the >> dictionary, including the product of lists with themselves (but you >> don't say why ;-)). >> >> I'm not sure the following is exactly what you want or if it is very >> efficient, but maybe it will start you off. It uses a function >> 'xcombine' taken from a recipe in the ASPN cookbook by David >> Klaffenbach (2004). >> > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302478 > > -- > http://mail.python.org/mailman/listinfo/python-list > >Thanks a lot Gerard and Roberto.but i think i should explain the exact >thing with an example. >Roberto what i have right now is concatenating the keys and the >corresponding values: >e.g {'a':[1,2],'b':[3,4,5],'c':[6,7]} should give me >{'ab':[1,2][3,4,5] 'ac':[1,2][6,7] 'bc':[3,4,5][6,7]} >The order doesnt matter here.It could be 'ac' followed by 'bc' and 'ac'. >Also order doesnt matter in a string:the pair 'ab':[1,2][3,4,5] is same as >'ba':[3,4,5][1,2]. >This representation means 'a' corresponds to the list [1,2] and 'b' >corresponds to the list [3,4,5]. >Now, for each key-value pair,e.g for 'ab' i must check each feature in the >list of 'a' i.e. [1,2] with each feature in list of 'b' i.e. [3,4,5].So I >want to take cartesian product of ONLY the 2 lists [1,2] and [3,4,5]. >Finally i want to check each pair if it is present in the file,whose >format i had specified. >The code Gerard has specified takes cartesian products of every 2 lists. Hi Garish, it's better to reply to the Group. >Now, for each key-value pair,e.g for 'ab' i must check each feature in the >list of 'a' i.e. [1,2] with each feature in list of 'b' i.e. [3,4,5].So I >want to take cartesian product of ONLY the 2 lists [1,2] and [3,4,5]. I'm confused. You say *for each* key-value pair, and you wrote above that the keys were the 'concatenation' of "every 2 keys of a dictionary". Sorry, too early for me. Maybe if you list every case you want, given the example data. All the best. Gerard -- http://mail.python.org/mailman/listinfo/python-list
using custom cookies in http
Hi, Im attemtping to set values of custom cookies and use it to gain access to certain web-pages that require these custom cookies. What I've done so far is creating the cookies like so: import Cookie C = Cookie.SmartCookie() C["__user_name"] = "foob" And Im trying to open a url that requires this cookie: import urllib f = urllib.urlopen("http://example.com/page/lies/here") print f.read() Now all Im missing is loading the cookie to urllib. How do I do this? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading from a file and converting it into a list of lines: code not working
On 6/06/2006 2:10 PM, Girish Sahani wrote: > I have a text file in the following format: > > 1,'a',2,'b' > 3,'a',5,'c' > 3,'a',6,'c' > 3,'a',7,'b' > 8,'a',7,'b' Check out the csv module. > . > . > . > Now i need to generate 2 things by reading the file: > 1) A dictionary with the numbers as keys and the letters as values. > e.g the above would give me a dictionary like > {1:'a', 2:'b', 3:'a', 5:'c', 6:'c' } > 2) A list containing pairs of numbers from each line. > The above formmat would give me the list as > [[1,2],[3,5],[3,6][3,7][8,7]..] > > I wrote the following codes for both of these but the problem is that > lines returns a list like ["1,'a',2,'b'","3,'a',5,'c","3,'a',6,'c'".] >Now due to the "" around each line,it is treated like one object > and i cannot access the elements of a line. You managed to split the file contents into lines using lines = open(filename).read().split("\n") Same principle applies to each line: |>>> lines = ["1,'a',2,'b'","3,'a',5,'c","3,'a',6,'c'"] |>>> lines[0].split(',') ['1', "'a'", '2', "'b'"] |>>> lines[1].split(',') ['3', "'a'", '5', "'c"] |>>> > > [code] > #code to generate the dictionary > def get_colocations(filename): > lines = open(filename).read().split("\n") > colocnDict = {} > i = 0 > for line in lines: > if i <= 2: > colocnDict[line[i]] = line[i+1] > i+=2 > continue > return colocnDict The return is indented too far; would return after 1st line. > [/code] > > [code] > def genPairs(filename): > lines = open(filename).read().split("\n") > pairList = [] > for line in lines: > pair = [line[0],line[2]] > pairList.append(pair) > i+=2 i is not defined. This would cause an exception. Please *always* post the code that you actually ran. > continue > return pairList dedented too far!! > [/code] > Please help :(( def get_both(filename): lines = open(filename).read().split("\n") colocnDict = {} pairList = [] for line in lines: n1, b1, n2, b2 = line.split(",") n1 = int(n1) n2 = int(n2) a1 = b1.strip("'") a2 = b2.strip("'") colocnDict[n1] = a1 colocnDict[n2] = a2 pairList.append([n1, n2]) return colocnDict, pairList def get_both_csv(filename): import csv reader = csv.reader(open(filename, "rb"), quotechar="'") colocnDict = {} pairList = [] for n1, a1, n2, a2 in reader: n1 = int(n1) n2 = int(n2) colocnDict[n1] = a1 colocnDict[n2] = a2 pairList.append([n1, n2]) return colocnDict, pairList HTH, John -- http://mail.python.org/mailman/listinfo/python-list
Re: the most efficient method of adding elements to the list
alf wrote: > Would it be .append()? Does it reallocate te list with each apend? No append does NOT reallocate for every call. Whenever a reallocation happens, the newsize is proportional to the older size. So you should essentially get amortized constant time for every append call. If you want to add a bunch of items in one call.. you should use the 'extend' method. Regards Sreeram signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading from a file and converting it into a list of lines: code not working
Girish Sahani wrote: > 1) A dictionary with the numbers as keys and the letters as values. > e.g the above would give me a dictionary like > {1:'a', 2:'b', 3:'a', 5:'c', 6:'c' } def get_dict( f ) : out = {} for line in file(f) : n1,s1,n2,s2 = line.split(',') out.update( { int(n1):s1[1], int(n2):s2[1] } ) return out > 2) A list containing pairs of numbers from each line. > The above formmat would give me the list as > [[1,2],[3,5],[3,6][3,7][8,7]..] def get_pairs( f ) : out = [] for line in file(f) : n1,_,n2,_ = line.split(',') out.append( [int(n1),int(n2)] ) return out Regards Sreeram signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: the most efficient method of adding elements to the list
alf wrote: > Would it be .append()? Does it reallocate te list with each apend? > > l=[] > for i in xrange(n): > l.append(i) No, it doesn't. It expands the capacity of the list if necessary. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis It isn't important to come out on top, what matters is to be the one who comes out alive. -- Bertolt Brecht, 1898-1956 -- http://mail.python.org/mailman/listinfo/python-list
Re: the most efficient method of adding elements to the list
> Hi, > > Would it be .append()? Does it reallocate te list with each apend? Yes it does. If order of the new element being added doesnt matter you can use append. If it does, you can use insert(). > > l=[] > for i in xrange(n): >l.append(i) > > > Thx, A. > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
the most efficient method of adding elements to the list
Hi, Would it be .append()? Does it reallocate te list with each apend? l=[] for i in xrange(n): l.append(i) Thx, A. -- http://mail.python.org/mailman/listinfo/python-list
Reading from a file and converting it into a list of lines: code not working
I have a text file in the following format: 1,'a',2,'b' 3,'a',5,'c' 3,'a',6,'c' 3,'a',7,'b' 8,'a',7,'b' . . . Now i need to generate 2 things by reading the file: 1) A dictionary with the numbers as keys and the letters as values. e.g the above would give me a dictionary like {1:'a', 2:'b', 3:'a', 5:'c', 6:'c' } 2) A list containing pairs of numbers from each line. The above formmat would give me the list as [[1,2],[3,5],[3,6][3,7][8,7]..] I wrote the following codes for both of these but the problem is that lines returns a list like ["1,'a',2,'b'","3,'a',5,'c","3,'a',6,'c'".] Now due to the "" around each line,it is treated like one object and i cannot access the elements of a line. [code] #code to generate the dictionary def get_colocations(filename): lines = open(filename).read().split("\n") colocnDict = {} i = 0 for line in lines: if i <= 2: colocnDict[line[i]] = line[i+1] i+=2 continue return colocnDict [/code] [code] def genPairs(filename): lines = open(filename).read().split("\n") pairList = [] for line in lines: pair = [line[0],line[2]] pairList.append(pair) i+=2 continue return pairList [/code] Please help :(( -- http://mail.python.org/mailman/listinfo/python-list
OT: unix newbie questions
Please help i am losing my mind ... UNIX Newbee 23. How do you add a line to the end of an existing file "myfile" with date stamp. (1) Ans : /home/clopez ed test.txt $a The last line of text. . w q 24. Display recent 10 java files, (with *.java extension) , in descending order by time, latest to oldest time. (1) Ans : 25. How do you set only read permissions to user, group and others in octal mode for a file "myfile.txt" ? (2) Ans: 26. You observed that some of your group members are fiddling with your file "myfile" and you wanted to remove the read permission to your group. How do you do? (1) Ans: 28. Here is another long listing of a file. (1) -rw-r- 1 Y435678 odms 20 Sep 02 17:03 file.txt. What are the owner permissions? read, execute read, write write, execute all since s/he is the owner Ans: 29. The file “users_data” has the following contents : (1) Tom Smith 7.00 15 105.00 Rob Sheryl 8.00 20 160.00 Ken Bradman 7.00 13 91.00 Peter Smith 6.00 15 90.00 Dennis Smith 8.00 13 104.00 Tom Dave 9.00 12 108.00 How do you sort the above file and redirect the output to another file called “sortedusers” Ans : 20. What is the command to list files in a directory : (2) A. Having only three alphabets: Ans: B. Starting with a digit and ending with a digit Ans: Carlos Lopez Computer Tech phone: (440)396-7474 email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Again, Downloading and Displaying an Image from the Internet in Tkinter
cannot help you with Tkinter but... save=open("image.jpg","wb") save.write(web_download.read()) save.close() perhaps this would let you open the file in Paint -- http://mail.python.org/mailman/listinfo/python-list
Re: How to generate all k-1 level substrings of a string?
Girish Sahani wrote: > I want to generate all substrings of size k-1 from a string of size k. > e.g 'abcd' should give me ['abc','abd','bcd','acd'] def get_sub_set( s ) : return [s[:i]+s[i+1:] for i in range(len(s))] >>> print get_sub_set( 'abcd' ) ['bcd', 'acd', 'abd', 'abc'] Regards Sreeram signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to pass a python function ptr to a c++ method from a python script?
"liam_herron" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > I have a core c++ library that is exposed to python through the > boost_python framework. > I would like to write the core of a Newton's method solver in C++ and > be able to write the > functions that are evaluated to be in python. Does anyone have any > ideas on this? > My suggestion would be to prototype in all-Python first. This will let you work out the kinks of your call/callback interfaces. Then see if the Newton's method part is a bottleneck worth converting to C++. My suspicion is that the performance (for all but trivial functions) will be in the function you are solving for, not in the Newton's metod. So be sure to test with a function that you feel is representative of those you want to solve for, not just a simple parabola. Then, stop thinking in C++. "Function pointer"? A function in Python is an object, a callable. You should be able to just treat it like one. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Get EXE (made with py2exe) path directory name
Andrei B wrote: > I need to get absolute path name of a file that's in the same dir as > the exe, however the Current Working Directory is changed to somthing > else. > Use sys.path[0] -- http://mail.python.org/mailman/listinfo/python-list
Re: Get EXE (made with py2exe) path directory name
try, if hasattr(sys, 'frozen'): me = sys.executable else: me = sys.argv[0] -- http://mail.python.org/mailman/listinfo/python-list
Get EXE (made with py2exe) path directory name
I need to get absolute path name of a file that's in the same dir as the exe, however the Current Working Directory is changed to somthing else. I turn my script into an executable with py2exe, then I create a shortcut to the EXE on the desktop. I change the "Start In" variable of the shortcut "C:\somthing_else", so now the currect working directory of the executable is not the same as the directory where the EXE is located. I need to load a file that's in the same directory as the EXE, so I do the following: dir = os.path.dirname(sys.argv[0]) filepath = os.path.join(dir, 'server.pkey') however it doesn't seem to work. Any idea? thanks! -- http://mail.python.org/mailman/listinfo/python-list
How to generate all k-1 level substrings of a string?
I want to generate all substrings of size k-1 from a string of size k. e.g 'abcd' should give me ['abc','abd','bcd','acd'] Order of these strings in the list doesnt matter. Also order doesnt matter inside the string e.g 'abc' or 'bca' or 'bac' is the same. I wrote the following code but it doesnt give the full output: subsetList = [] for element in prunedNew: for i in range(0,2): subsetList.append(element[i:i+len(element)-1]) continue continue return prunedNew Thanks in Advance, girish -- http://mail.python.org/mailman/listinfo/python-list
Re: Expanding Search to Subfolders
>>> Could someone tell me where to learn more about directory >>> processes or show me an improved version of my first >>> script snippet? Use os.walk http://docs.python.org/lib/os-file-dir.html It takes a little reading to get it if you are a beginner, but there are zillions of examples if you just search this Google Group on "os.walk" http://tinyurl.com/kr3m6 Good luck rd "I don't have any solution, but I certainly admire the problem."--Ashleigh Brilliant -- http://mail.python.org/mailman/listinfo/python-list
Re: check for dictionary keys
On 5/06/2006 10:46 PM, Bruno Desthuilliers wrote: > [EMAIL PROTECTED] a écrit : >> hi >> in my code, i use dict(a) to make to "a" into a dictionary , "a" comes >> from user input, so my program does not know in the first place. Then >> say , it becomes >> >> a = { '-A' : 'value1' , '-B' : "value2" , "-C" : "value3" , '-D' : >> 'value4' } >> >> somewhere next in my code, i will check for these..: >> >> 1) -A and -B cannot exist together >> 2) -A and -C cannot exist together >> 3) -A and -B and -D cannot exist together >> 4) and lots of other combinations to check for > > Looks like an option parser... If so, there's all you need in the > standard lib (look for the optparse module). > >> >> how can i efficiently check for the above? At first as i do simple >> checks , i use if and else. >> But as i began to check for more combinatoiuns, it gets messy > > First : use boolean logic (truth table, Kernaugh diagram, etc) to > simplify things. As an example, rule #3 is useless - it's a subset of > rule #1 (-A and -B and -D implies -A and -B). This should greatly reduce > the number of needed tests. Good idea, but doesn't scale well. Simple code can weed out redundant rules, including any accidental duplicates that may creep into a long list. See code listing at end. > > Then, write a simple rule system describing either valid inputs or > invalid inputs (preferably the smallest set !-). FWIW, it can be as > simple as a list of lambdas/error messages pairs, with lambdas being > predicate taking dict keys as params: > > > _RULES = [ > (lambda keys : '-A' in keys and '-B' in keys, >"can't have both options -A and -B"), > (lambda keys : '-A' in keys and '-C' in keys, >"can't have both options -A and -C"), > # etc... > ] > The evil HR director won't let the PHB pay me on a per LOC basis, so I've had to come up with a compact table-driven approach :-) > def validate(options, rules): > keys = options.keys() > for predicate, message in rules: > if not predicate(keys): > raise ValueError(message) Cheers, John C:\junk>type option_combos.py bad_combos = ['ABD', 'AC', 'AB', 'CA'] def rule_compaction(bc_list, verbose=False): # The next few lines are admittedly oldfashioned :-) bc_sets = [set(x) for x in bc_list] deco = [(len(y), y) for y in bc_sets] deco.sort() bc_sets = [z[1] for z in deco] del deco if verbose: print "bc_sets #1:", bc_sets for k in xrange(len(bc_sets)-1, 0, -1): candidate = bc_sets[k] for ko in bc_sets[:k]: if ko <= candidate: if verbose: print candidate, "knocked out by", ko del bc_sets[k] break if verbose: print "bc_sets #2:", bc_sets return bc_sets option_rules = rule_compaction(bad_combos, verbose=True) def combo_disallowed_by(opt_set, rules): for rule in rules: if opt_set >= rule: return rule return None # redundantly, for emphasis if __name__ == "__main__": import sys for opt_string in sys.argv[1:]: failer = combo_disallowed_by(set(opt_string), option_rules) if failer: print repr(opt_string), "disallowed by", failer else: print repr(opt_string), "is OK" === a test === C:\junk>option_combos.py A AB AC AD BC ABD ABX XBA BX bc_sets #1: [set(['A', 'C']), set(['A', 'B']), set(['A', 'C']), set(['A', 'B', 'D'])] set(['A', 'B', 'D']) knocked out by set(['A', 'B']) set(['A', 'C']) knocked out by set(['A', 'C']) bc_sets #2: [set(['A', 'C']), set(['A', 'B'])] 'A' is OK 'AB' disallowed by set(['A', 'B']) 'AC' disallowed by set(['A', 'C']) 'AD' is OK 'BC' is OK 'ABD' disallowed by set(['A', 'B']) 'ABX' disallowed by set(['A', 'B']) 'XBA' disallowed by set(['A', 'B']) 'BX' is OK === the end === -- http://mail.python.org/mailman/listinfo/python-list
Re: Again, Downloading and Displaying an Image from the Internet in Tkinter
I wrote: > Nobody answered last time. I guess they wanted me to give it a shot. > Well, here is how I download the image (it's a class method): > > def download_image(self): > web_download=self.opener.open(self.url) > save=open("image.jpg","w") > save.writelines(web_download.readlines()) > save.close() > web_download.close() > > self.opener is urllib.URLopener(), self.url is the url for the image. > > I display the image as follows: > > self.image=t.Label(self.frame,image=path+"\\image.jpg") > > t is Tkinter, path is sys.path[0]. > (if sys.path[0] is not the proper way of getting the program's path, > inform me; I hunted it down without any reference to look to) > > > But the image won't display, using any application (including Tkinter, > paint, Firefox, etc.). I'm assuming the reason it can't be read is > because the image is protected from downloading. > > So, once again, is there a better way to download and display an image > using Tkinter? > > Did I try hard enough for you? Are you going to help me this time? I should probably also mention, the only reason I downloaded the image to a file was because I don't know of any other way to do it. I feel no need to save the image to my hard drive. -- http://mail.python.org/mailman/listinfo/python-list
Is there a way to pass a python function ptr to a c++ method from a python script?
I have a core c++ library that is exposed to python through the boost_python framework. I would like to write the core of a Newton's method solver in C++ and be able to write the functions that are evaluated to be in python. Does anyone have any ideas on this? -- http://mail.python.org/mailman/listinfo/python-list
Again, Downloading and Displaying an Image from the Internet in Tkinter
Nobody answered last time. I guess they wanted me to give it a shot. Well, here is how I download the image (it's a class method): def download_image(self): web_download=self.opener.open(self.url) save=open("image.jpg","w") save.writelines(web_download.readlines()) save.close() web_download.close() self.opener is urllib.URLopener(), self.url is the url for the image. I display the image as follows: self.image=t.Label(self.frame,image=path+"\\image.jpg") t is Tkinter, path is sys.path[0]. (if sys.path[0] is not the proper way of getting the program's path, inform me; I hunted it down without any reference to look to) But the image won't display, using any application (including Tkinter, paint, Firefox, etc.). I'm assuming the reason it can't be read is because the image is protected from downloading. So, once again, is there a better way to download and display an image using Tkinter? Did I try hard enough for you? Are you going to help me this time? -- http://mail.python.org/mailman/listinfo/python-list
Re: C# equivalent to range()
Fredrik Lundh wrote: > do you think the few of us who haven't already done so would miss > anything if we plonked you now? Oh, no... How am I supposed to live without you, Freddie? -- http://mail.python.org/mailman/listinfo/python-list
Re: PyOpenSSL and PyCrypto are outdated!
Thank you Terry. I searched but didn't get useful information. In fact, I've built pycrypto 2.0.1 successfully. However, the source of pyOpenSSL seemed to be incompatible with lastest OpenSSL 0.98b. I tried to build it and got dozens of compile errors which complain about syntax error in x509v3.h. My C++ compiler is Visual C++ 7.1. Should I use older OpenSSL release? Terry Reedy 写道: > "Mike Meng" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > >I'm learning Twisted and downloaded pyOpenSSL and pycrypto win32 > > installer on http://twisted.sourceforge.net/contrib/ . But I find the > > lastest version are for Python 2.3. I try to rebuild pyOpenSSL from > > source, but get lots of compile errors. Are these two packages > > obsolated? Where can I find updated version? > > Did you try Google? This question has been asked before. -- http://mail.python.org/mailman/listinfo/python-list
Re: C# equivalent to range()
Luis M. González wrote: > Fuzzyman wrote: >> FWIW I agree. If anyone didn't want to answer the question they didn't >> need to. >> >> Why be rude to someone asking a polite question. It's not as if there >> isn't much more *worse* noise on this group. > > The poster asked the question very politely, apologizing in advance for > what may be consider an off-topyc question. Beginning a post by demonstrating that you know you are violating the conventions of the group is _in_and_of_itself_ rude, and hence even the first post was not a polite question. If this were not true, then all manner of spam would be polite. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Expanding Search to Subfolders
>> there are far easier ways >> #!/bin/bash >> cat *.txt >outputfile Well, yes, but if he's kicking things off with: >> os.chdir("C:\\Python23\\programs\\filetree") I'm guessing he's not on Linux. Maybe you're trying to convert him? rd -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to C converter
If you are looking for a "real" python to C, well in this case C++ look for the shedskin compiler. It will take a rather nice subset of Python and generate C++ code from it. It is still rather experimental but I have been using it. Chance G. On Mon, 05 Jun 2006 07:19:39 -0700, Fuzzyman wrote: > > gene tani wrote: >> Rene Pijlman wrote: >> > [EMAIL PROTECTED]: >> > >I have an application return in python. I want this to be >> > >converted to C. >> > >> > http://www.python.org/doc/faq/general/#can-python-be-compiled-to-machine-code-c-or-some-other-language >> > >> >> http://pyfaq.infogami.com/can-python-be-compiled-to-machine-code-c-or-some-other-language >> shd probably mention Shedskin, boost, ctypes, any others? > > The PyPy LLVM backend will compile Python code to C. > > Also Pyrex can do a bit more than just integrate C with Python, AFAIK > it *can* compile some Python to C - although with very little speed > advantage if you don't use native C types. > > Fuzzyman > http://www.voidspace.org.uk/python/index.shtml -- http://mail.python.org/mailman/listinfo/python-list
Re: Software Needs Philosophers
He means Lisp macros. Lisp macros are nothing like the crippled C++ macros that people tend to think of. Roedy Green wrote: > On 21 May 2006 02:15:31 -0700, "Xah Lee" <[EMAIL PROTECTED]> wrote, > quoted or indirectly quoted someone who said : > > > Java has lots of macro languages, including C++'s preprocessor. What > it does not have is a sanctioned one. It has instead on-the-fly code > generation. See http://mindprod.com/jgloss/onthefly.html > > > -- > Canadian Mind Products, Roedy Green. > http://mindprod.com Java custom programming, consulting and coaching. -- http://mail.python.org/mailman/listinfo/python-list
Re: strategy pattern and non-public virtual functions
[EMAIL PROTECTED] a écrit : > Hi python experts > > In C++ I can do something like this: > class Base { > public: > void f() { this->f_(); } > private: > virtual void f_() = 0; > }; > > class Derived : public Base { > private: > void f_() { // Do something } > }; > > int main() { > Derived d; > d.f(); > } This is eventually the template method pattern, but certainly not the strategy pattern. > The point of this is that the a number of classes will inherit from > Base and only implement a private member function that only will be > accessed from the base class public 'f' function. > The Base::f() can then perform validation of input/return values, add > logging and things like that. This is usually done in Python with function decorators. But the implementer of the derived class (snip - cf other posts in this thread) > So my questions are: > 1. Is there a "pythonic" way to do what I'm trying to do? > > 2. Should I be doing this at all? Any thoughts? Doing what ? adding logging, validation etc, or using the template method pattern ?-) -- http://mail.python.org/mailman/listinfo/python-list
Re: follow-up to FieldStorage
John Salerno a écrit : > If I want to get all the values that are entered into an HTML form and > write them to a file, is there some way to handle them all at the same > time, or must FieldStorage be indexed by each specific field name? AFAIK, FieldStorage is a somewhat dict-like object, but I'm not sure it supports the whole dict interface. At least, it does support keys(), so you should get by with: for k in fs.keys(): print >> myfile, k, ":", fs[k] But reading the doc may help... -- http://mail.python.org/mailman/listinfo/python-list
Re: Storing nothing in a dictionary and passing it to a function
[EMAIL PROTECTED]: > I'd like to have a dictionary (actually a nested dictionary) to call > these functions so I can avoid if-then-elsing everything. Eath > dictionary item has three things in it: the function to be called, a > string to pass to the function (which is also the key to the dict), and > a tuple to pass to the function. In the case of the function with no > arguments, obviously I'd like not to pass anything. [...] > something like this: > alldict = \ > {'pulse': {'func': self.arbtrandef, 'args':(2,5)},\ > 'sin' : {'func': self.arbtrandef, 'args':(2,3)},\ > 'exp' : {'func': self.arbtrandef, 'args':(2,4)},\ > 'pwl' : {'func': self.pwldef, 'args': > (None,)},\ <--- how > do I store "no" arguments? > 'sffm' : {'func': self.arbtrandef, 'args':(5,0)}} > > for it in alldict.items(): > name = it[0] > args = (name,) + it[1]['args'] > it[1]['func'](*args) I would do it like this: alldict = { 'pulse': (self.arbtrandef, (2, 5)), # function and args packed in a tuple 'sin' : (self.arbtrandef, (2, 3)), 'exp' : (self.arbtrandef, (2, 4)), 'pwl' : (self.pwldef, ()),# empty tuple represented by () 'sffm' : (self.arbtrandef, (5, 0)), } for (fname, (func, args)) in alldict.items(): # items unpacked directly func(fname, *args) Best regards. -- Roberto Bonvallet -- http://mail.python.org/mailman/listinfo/python-list
Re: C# equivalent to range()
Robert Kern wrote: > Fuzzyman wrote: > > Erik Max Francis wrote: > > >>Here were the "harsh" and "whining" responses to his question he's > >>complaining about: > > > > Fair enough. Maybe they weren't "harsh" and "whining", just patronising > > and abrupt. > > Welcome to USENET! Well, this is true. Doesn't make it a *good* thing of course... :-) Fuzzyman http://www.voidspace.org/python/shareware.shtml > > -- > Robert Kern > > "I have come to believe that the whole world is an enigma, a harmless enigma > that is made terrible by our own mad attempt to interpret it as though it had > an underlying truth." > -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: C# equivalent to range()
Fuzzyman wrote: > Erik Max Francis wrote: >>Here were the "harsh" and "whining" responses to his question he's >>complaining about: > > Fair enough. Maybe they weren't "harsh" and "whining", just patronising > and abrupt. Welcome to USENET! -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: Adding attribute to objetcs
faulkner a écrit : (please, don't top-post - corrected) > > Miguel Galves wrote: > >>Hello, >> >>I`m starting to learn python, and I hava a very good background in Java >>and C/C++ programming. I was reading Dive into python chapter about >>OO and I saw that in python we can do the following: >> >>class Person: Do yourself a favor : use new-style classes class Person(object): >>pass >> >>joe = new Person() joe = Person() No 'new' keyword needed - Python classes are callable objects acting as factory. >>joe.name = "Joe" >>joe.age = 13 >> >>It seems that it is possible to add attributes to any object instance >>in run time, as in Javascript. Yes, unless you used __slots__ in your class. >> It seems to me that it can be a source >>of errors. Almost never happened to me in 7+ years of Python programming. > One that come in my mind is the follwing: >> >>class Person: >>name = "" This creates a class attribute (ie: shared by all instances of the class). For an instance attribute, you want this: class Person(object): def __init__(self, name="") self.name = name >>joe = new Person() >>joe.nome = "Joe" >> >>The code above adds an attribute called nome, but the programmer may think >>it's name. Then he haven't read it's code !-) >>What is the real interest of this feature ? Doing things you can't even dream of in Java or C++. Now if this scares you, what about dynamically adding/replacing a method to/of a whole class or on a per-instance basis, or changing the class of an object at runtime ?-) > Is there a way to block this >>kind of error ? If you're serious, you use automated unit tests, and you'll notice the error pretty quickly. Even if you don't use automated unit-tests, the test/code cycle in Python is so fast that you'll still notice the problem pretty soon. And also, there are tools like pylint that may help you catch a lot of typos. Now in practice, I can assure you this is nothing to worry about. Since Python doesn't get in the way, one usually stay very focused on the actual code being written instead of fighting with boiler-plate. > when you set an attribute of an object, python secretly calls that > objects __setattr__ method. > class test: *please* use new-style classes. > def __setattr__(self, attr_name, attr_value): > print self, attr_name, attr_value stdout is for normal program outputs. Trace etc should go either to a log and/or to stderr. > self.__dict__[attr_name] = attr_value# do what the original > __setattr__ method does. And ? How will this "block this kind of error" ? Are you suggesting to test for names in __setattr__ ? This would be totally stupid IMHO. Python *is* dynamic. period. Better to go with the language than to try to force it into a brain-dead mockup of Java. -- http://mail.python.org/mailman/listinfo/python-list
Re: C# equivalent to range()
Fuzzyman wrote: > FWIW I agree. If anyone didn't want to answer the question they didn't > need to. > > Why be rude to someone asking a polite question. It's not as if there > isn't much more *worse* noise on this group. I also agree. Although the question may have appeared out of place, it wasn't totally. The poster asked the question very politely, apologizing in advance for what may be consider an off-topyc question. He also said he only knew python, and he probably wasn't able to explain the intended behaviour he wanted in C# without refering to Python. He is also very right when he says that those who were not interested in the question could have simply ignored it. In exchange, he got a couple of slighty rude replies and an ironic comment. What reaction do you expect from him? -- http://mail.python.org/mailman/listinfo/python-list
Re: C# equivalent to range()
Erik Max Francis wrote: > Fuzzyman wrote: > > > FWIW I agree. If anyone didn't want to answer the question they didn't > > need to. > > > > Why be rude to someone asking a polite question. It's not as if there > > isn't much more *worse* noise on this group. > > Here were the "harsh" and "whining" responses to his question he's > complaining about: > Fair enough. Maybe they weren't "harsh" and "whining", just patronising and abrupt. Fuzzyman http://www.voidspace.org.uk/python/index.shtml > | Bad guess. Ask questions about language X on comp.lang.X > > | Really, it isn't. Post in a C# discussion forum, describing the > | behaviour you want from your program. > > | *Very* strong suggestion - read the following link: > | > | http://www.catb.org/~esr/faqs/smart-questions.html > > Sorry, if you think those are unacceptable tones for responses to > off-topic questions, the real world is going to be something of an > unpleasant shock. > > He asked a question. He was told how to get the answer. No one was > rude until _he_ started being rude. > > -- > Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ > San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis >Society attacks early when the individual is helpless. >-- B.F. Skinner -- http://mail.python.org/mailman/listinfo/python-list
Re: C# equivalent to range()
Neuruss wrote: > The other zilion persons who were not interested (other than the four I > mentioned above) silently and peacefully ignored the question on went > on with their happy lifes. That's because many of them have killfiled you. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis Society attacks early when the individual is helpless. -- B.F. Skinner -- http://mail.python.org/mailman/listinfo/python-list
Re: C# equivalent to range()
Fuzzyman wrote: > FWIW I agree. If anyone didn't want to answer the question they didn't > need to. > > Why be rude to someone asking a polite question. It's not as if there > isn't much more *worse* noise on this group. Here were the "harsh" and "whining" responses to his question he's complaining about: | Bad guess. Ask questions about language X on comp.lang.X | Really, it isn't. Post in a C# discussion forum, describing the | behaviour you want from your program. | *Very* strong suggestion - read the following link: | | http://www.catb.org/~esr/faqs/smart-questions.html Sorry, if you think those are unacceptable tones for responses to off-topic questions, the real world is going to be something of an unpleasant shock. He asked a question. He was told how to get the answer. No one was rude until _he_ started being rude. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis Society attacks early when the individual is helpless. -- B.F. Skinner -- http://mail.python.org/mailman/listinfo/python-list
Re: Python + WinCE + serial port
pcm wrote: > Fuzzyman wrote: > > > > > pcm wrote: > >> Hi, > >> > >> Has anyone ever worked on a Python-WinCE-based program that involved > >> serial port management ? > >> > > > > Because of the size of the runtime and the fragility of the GUI > > toolkits, there has been little serious development with PythonCE. > > (Little not none - and it's great to have Python available.) > > > > There is no built in support for the serial port in PythonCE (AFAIK). > > Your best bet is using ctypes (for which a PythonCE port has been done) > > and the microsoft API. > > > > Fuzzyman > > http://www.voidspace.org.uk/python/index.shtml > > > >> Regards, > >> > >> Philippe > > > > > Thanks, does that mean that I need to write an extension to the WinCE API or > is that built-into the Python package ? > (Sorry for late reply.) There is a version of ctypes *compiled* for PythonCE (from the PythonCE sourceforge page). Using ctypes you should be able to use the Microsoft Win32 API to access the serial port from *pure Python* code. You will need to use the Microsoft docs to see which calls to make. Fuzzyman http://www.voidspace.org.uk/python/index.shtml > Regards, > Philippe -- http://mail.python.org/mailman/listinfo/python-list
Re: C# equivalent to range()
Neuruss wrote: > Erik Max Francis wrote: > > > I'm curious, who are "us"? > > > > The regular readers of comp.lang.python. If you don't think we haven't > > seen this a zillion times before, you're kidding yourself. > > > > If you want help on a language, ask in that language's newsgroup/mailing > > list/forum/whatever. > > > > It surprises me how often people don't ask useful questions, or > > deliberately and knowingly ask questions in the wrong places, and then > > actually _defend_ their actions after they're politely but firmly > > informed how to fix the problem. You're really not making yourself look > > any better by continuing this thread ... > > Just to finish this thread: > 1) It wasn't a blunt question. I started the post apologizing for the > (not entirely) off opic question. > 2) I wasn't politely informed. It was pretty harshly. > 3) If you mean that "us" are the zillion registered users of this > mailing list, well buddy, you know a whole lot of people! > 4) At least one of these people replied kindly and correctly to my > question within seconds. Three of four more spent several minutes > whining. > The other zilion persons who were not interested (other than the four I > mentioned above) silently and peacefully ignored the question on went > on with their happy lifes. > FWIW I agree. If anyone didn't want to answer the question they didn't need to. Why be rude to someone asking a polite question. It's not as if there isn't much more *worse* noise on this group. Fuzzyman http://www.voidspace.org.uk/python/index.shtml > À bientôt, > Neuruss -- http://mail.python.org/mailman/listinfo/python-list
Re: Little question about Tkiner: window focus
Bernard Lebel wrote: > Hello, > > I have this Tkinter window that when you click on a certain button, > another instance of Tk is created, and thus a new windows is spawned. > That second windows holds a few widgets to browse files and > directories. > > Now, as soon as I start browsing files and directories, the first > window comes back in focus. I have to click the second window to put > the focus back there. > > My question is: is there a way to force the focus of a given Tk > instance? I'm using the Toplevel widget to create those second > windows. I have looked into the "takefocus" option, but doesn't seem > to have any effect. > > I'm using Python 2.4 on Windows XP Pro SP1. > > > Thanks > Bernard You should post a code snippet so we can see if there is anything amiss. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: C# equivalent to range()
Luis M. González wrote: > There are thousands of threads to choose from in this forum. > If they didn't like this question, they could have picked any other one > to discuss. > There's no need to be disagreeable :-) Plenty of people _did_ helpfully respond to his question with the right answer. The right answer is: This is the wrong forum; as your question in a C#-related forum. It was then the _original poster_ who became "disagreeable" by assigning motive to the people who _actually helped him_ by telling him the right place to ask his question, saying that the "enjoy to waste their time niggling." He's complaining that people weren't nice to help. But they _were_. They answered his question politely and to the point. It's _he_ that turned rude after that. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis What a crime to waste [youth] on children. -- George Bernard Shaw -- http://mail.python.org/mailman/listinfo/python-list
RE: C# equivalent to range()
*Very* strong suggestion - read the following link: http://www.catb.org/~esr/faqs/smart-questions.html Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list
RE: Which exceptions are recommended to me handled?
Fredrik Lundh wrote: > Delaney, Timothy (Tim) wrote: > >> The most important problem here is that you've lost the stack trace from >> the original exception. > > which, in many cases, is a good thing, especially if you replace "int" > with a call to some low-level support library. if I call API "foo" to > open a data file of some kind, I'm not necessarily interested in an > "unsubscriptable error" exception on line 129 in barpath.py, nor is it > helping me figure out what's wrong in my program. I always prefer to have the stack trace, since it *is* useful to me to figure out what is wrong with my program (or possibly, the library I'm using). > or do you expose internal implementation details to your end users > too, to make sure they don't lose any information? No - but I do log any errors, with stack traces, and as much useful data as possible. That way it's more likely that I can get a useful bug report (they send the log file). Replacing an exception *may* not get in the way if you're wrapping a single statement in the exception. I can't think of another case where it would not get in the way. Chained exceptions change this somewhat, because you don't lose the original information. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list
Re: Adding attribute to objetcs
when you set an attribute of an object, python secretly calls that objects __setattr__ method. class test: def __setattr__(self, attr_name, attr_value): print self, attr_name, attr_value self.__dict__[attr_name] = attr_value# do what the original __setattr__ method does. test().fred = 'george'# prints fred george Miguel Galves wrote: > Hello, > > I`m starting to learn python, and I hava a very good background in Java > and C/C++ programming. I was reading Dive into python chapter about > OO and I saw that in python we can do the following: > > class Person: > pass > > joe = new Person() > joe.name = "Joe" > joe.age = 13 > > It seems that it is possible to add attributes to any object instance > in run time, as in Javascript. It seems to me that it can be a source > of errors. One that come in my mind is the follwing: > > class Person: > name = "" > > joe = new Person() > joe.nome = "Joe" > > The code above adds an attribute called nome, but the programmer may think > it's name. > > What is the real interest of this feature ? Is there a way to block this > kind of error ? > > Thanks, > > Miguel > -- > Miguel Galves - Engenheiro de Computação > Já leu meus blogs hoje? > Para geeks http://log4dev.blogspot.com > Pra pessoas normais > http://miguelgalves.blogspot.com > > "Não sabendo que era impossível, ele foi lá e fez..." -- http://mail.python.org/mailman/listinfo/python-list
Re: xml.sax problem: getting parse() to read a string
Fredrik Lundh wrote: > as mentioned in the documentation, and implied by my answer, parseString > is a helper function in the xml.sax module, not a parser method. try doing > > xml.sax.parseString(string, handler) > > instead of that make_parser/setContentHandler/parse dance. > > Thanks a ton for all your help! I have successfully moved past this obstacle, with much appreciated thanks to your postings here (and other postings of yours I found via google). -- lucas -- http://mail.python.org/mailman/listinfo/python-list
Re: ConfigParser, no attribute
Settings.__init__ needs to call ConfigParser.SafeConfigParser.__init__ before it calls self.readfp. Nexu wrote: > Hello, > > I'm not sure exactly what i'm doing wrong here. I asked around on IRC > and i was told the code is correct. > The purpose of Settings() is that whenever Settings() or any of its > methods are called. It should pick up the latest settings from file > instead of returning what was in the buffer. This allow other scripts to > change the value and my program and pick these changes up. > Everything else should work exact same as ConfigParser(). > - > class Settings(ConfigParser.SafeConfigParser): > def __init__(self): > self.filename = os.path.join(xchat.get_info('xchatdir'), > 'nxscript', > 'nxscript.conf') > try: > config_file = file(self.filename, 'r') > self.readfp(config_file, self.filename) > if self.sections() == []: > self.add_section('Global') > if self.has_section('Global'): > self.set('Global', 'ProtectME', 'false') > config_file.close() > except IOError: > nx.sysmsg('Configuration file not found') > > def update_file(self): > try: > config_file = file(self.filename, 'w') > self.write(config_file) > except IOError: > nx.sysmsg('Could not write to configuration file') > - > SAMPLE CODE (what i want to able to do): > setting = Settings() > if setting.get('Global', 'ProtectME'): > print 'protection enabled' > - > ERRORS: >File "/home/nexu/.xchat2/nxscript/nx.py", line 43, in ? > setting = Settings() >File "/home/nexu/.xchat2/nxscript/nx.py", line 24, in __init__ > self.readfp(config_file, self.filename) >File "/usr/lib/python2.4/ConfigParser.py", line 286, in readfp > self._read(fp, filename) >File "/usr/lib/python2.4/ConfigParser.py", line 451, in _read > if sectname in self._sections: > AttributeError: Settings instance has no attribute '_sections' -- http://mail.python.org/mailman/listinfo/python-list
Re: GUI Program Error
Bernard Lebel wrote: > Unless you were being sarcastic? ;-) Just temporarily dense. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: C# equivalent to range()
Neuruss wrote: > [more childish blah blah blah] do you think the few of us who haven't already done so would miss anything if we plonked you now? -- http://mail.python.org/mailman/listinfo/python-list
Re: Large Dictionaries
In article <[EMAIL PROTECTED]>, Tim Peters <[EMAIL PROTECTED]> wrote: >[Jim Segrave] >> Actually, presorted lists are not a bad case for heapsort - it's quite >> immune to any existing order or lack thereof, > >Write a heapsort and time it. It's not a difference in O() behavior, >but more memory movement is required for a sorted list because >transforming the list into a max-heap at the start requires shuffling >the largest elements from the end of the list to its start. Initially >reverse-sorted is a "good case" for heapsort in the same sense >(because the list is already a max-heap then; initially sorted is as >far from being a max-heap as is possible). "good" and "bad" are both >O(N log N) here, though. I did implement a crude heapsort before posting this and measured the number of comparisions and the number of swaps. == #!/usr/local/bin/python import random class HeapSorter(object): def __init__(self, seq): self.compares = 0 self.swaps = 0 self.length = len(seq) self.seq = seq def __sift(self, i): while True: j = 2 * i + 1 if j + 1 < self.length: self.compares += 1 if self.seq[j + 1] > self.seq[j]: j = j + 1 if j >= self.length: return self.compares += 1 if self.seq[i] > self.seq[j]: return self.swaps += 1 self.seq[i], self.seq[j] = (self.seq[j], self.seq[i]) i = j def __makeheap(self): for i in range(self.length / 2, -1, -1): self.__sift(i) def sort(self): self.__makeheap() for i in range(self.length - 1, -1, -1): self.swaps += 1 self.seq[i], self.seq[0] = (self.seq[0], self.seq[i]) self.length -= 1 self.__sift(0) if __name__ == '__main__': s = list(range(10)) random.shuffle(s) heap = HeapSorter(s) heap.sort() print "Random list: comapres %d, swaps %d" % \ (heap.compares, heap.swaps) heap = HeapSorter(s) heap.sort() print "Sorted list: comapres %d, swaps %d" % \ (heap.compares, heap.swaps) s.reverse() heap = HeapSorter(s) heap.sort() print "Reverse Sorted list: comapres %d, swaps %d" % \ (heap.compares, heap.swaps) == Which gave the following results: /usr/home/jes% python ./heapsort Random list: comapres 3019969, swaps 1575263 Sorted list: comapres 3112517, swaps 1650855 Reverse Sorted list: comapres 2926640, swaps 1497435 Assuming compares and swaps dominate other bookkeeping, then heapsort is quite stable in its performance, although the constant in the O(N log N) is much larger than for other sorts. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list
Re: xml.sax problem: getting parse() to read a string
[EMAIL PROTECTED] wrote: > I am getting the following error. > > File "acmtest.py", line 205, in parseMessage > parser.parseString(message) > AttributeError: ExpatParser instance has no attribute 'parseString' > > Am I simply missing that library here? Or am I calling it incorrectly? as mentioned in the documentation, and implied by my answer, parseString is a helper function in the xml.sax module, not a parser method. try doing xml.sax.parseString(string, handler) instead of that make_parser/setContentHandler/parse dance. -- http://mail.python.org/mailman/listinfo/python-list
Re: GUI Program Error
On 6/5/06, John Salerno <[EMAIL PROTECTED]> wrote: > What is dir(), btw? Is it a class for creating the application? [Bernard] In your Python documentation, dir() is described in the built-in functions (section 2.1) as well as the tutorial, in the "Modules" section (chapter 6). Unless you were being sarcastic? ;-) Bernard -- http://mail.python.org/mailman/listinfo/python-list
Re: GUI Program Error
John Salerno wrote: > What is dir(), btw? Is it a > class for creating the application? Heh heh, how quickly I forget about built-ins. :) Try something like this: import Tkinter as tk root = tk.Tk() label = tk.Label(root, text='Hello world!') label.pack() root.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: GUI Program Error
Byte wrote: > Hi, I'm using the "Learning to Program" GUI tutorial on > http://www.freenetpages.co.uk/hp/alan.gauld/ > and am trying to write my first GUI. However, the code the tutorial > gives for starting by making a window: > > > import Tkinter > > top = Tkinter.Tk() > > dir(top) > > Does not work. The Python interpreter does not complain about anything, > but the window the tutorial promises will apperar will not. I'm using > Python 2.4.2 and the Eric 3.7.0 IDE on Ubuntu 5.10. Anybody know what > to do? You have to call top.mainloop() for it work. What is dir(), btw? Is it a class for creating the application? -- http://mail.python.org/mailman/listinfo/python-list
Re: strategy pattern and non-public virtual functions
[EMAIL PROTECTED] writes: > Hi python experts > > In C++ I can do something like this: > class Base { > public: > void f() { this->f_(); } > private: > virtual void f_() = 0; > }; > > class Derived : public Base { > private: > void f_() { // Do something } > }; > > int main() { > Derived d; > d.f(); > } [...] The others have already answered the Python question and pointed out this isn't really the Strategy Pattern. Still, these slides from Alex Martelli specifically on the Template Method DP in Python are probably very relevant to you: http://www.aleax.it/Python/os03_template_dp.pdf John -- http://mail.python.org/mailman/listinfo/python-list
Re: how not to run out of memory in cursor.execute
On Mon, Jun 05, 2006 at 07:34:05PM +0100, Steve Holden wrote: > amberite wrote: > > [EMAIL PROTECTED] wrote: > > > >>I am using cx_Oracle and MySQLdb to pull a lot of data from some tables > >>and I find that the cursor.execute method uses a lot of memory that > >>never gets garbage collected. Using fetchmany instead of fetchall does > >>not seem to make any difference, since it's the execute that uses > >>memory. Breaking the query down to build lots of small tables doesn't > >>help, since execute doesn't give its memory back, after reading enough > >>small tables execute returns a memory error. What is the trick to get > >>memory back from execute in cx_Oracle and MySQLdb? > > > > > > cx_Oracle and MySQLdb must be handled differently, due to the fact that > > MySQL does not actually have cursors (MySQLdb fakes them for you). > > > > To handle large resultsets efficiently in cx_Oracle simply use the > > cursor iteration idiom: > > > > for row in cursor: > > # do stuff with the row > > > > cx_Oracle takes care of the fetching for you, and your memory usage > > should remain fairly constant when using this idiom. > > > > To handle large resultsets in MySQLdb, you have to resort to multiple > > queries: > > > > l = 1000 > > o = 0 > > > > cursor.execute('SELECT foo FROM Bar LIMIT %d OFFSET %d', (l, o)) > > rows = cursor.fetchall() > > while len(rows) > 0: > > # process the fetched rows > > o += l > > cursor.execute('SELECT foo FROM Bar LIMIT %d OFFSET %d', (l, o)) > > rows = cursor.fetchall() > > > > cursor.close() > > > > As you can see, the MySQLdb version is more involved, due to the lack > > of real cursor support in the MySQL database. Any database with good > > cursor support will likely have good cursor iteration support in the > > corresponding DBAPI driver. > > > > Hope this helps, > > > > L. Daniel Burr > > > The MySQLdb solution you give is way more complicated than it needs to > be, thereby skewing your opinion towards cx_Oracle unnecessarily. > > Look up the .fetchmany() method of cursors in the DB API. There is only > any need to execute a single query no matter how large the result set: > you simply need to keep calling .fetchmany(N) (where N is whatever > you've decided by testing is your optimum chunk size) until it returns > less than N rows, at which point you have exhausted the query. > > It's very little more effort to wrap this all up as a generator that > effectively allows you to use the same solution as you quote for cx_Oracle. MySQL will keep table locks until the results are all fetched so even though the DB API allows fetchone() or fetchmany() using those with MySQLdb is dangerous. -Jack -- http://mail.python.org/mailman/listinfo/python-list
GUI Program Error
Hi, I'm using the "Learning to Program" GUI tutorial on http://www.freenetpages.co.uk/hp/alan.gauld/ and am trying to write my first GUI. However, the code the tutorial gives for starting by making a window: import Tkinter top = Tkinter.Tk() dir(top) Does not work. The Python interpreter does not complain about anything, but the window the tutorial promises will apperar will not. I'm using Python 2.4.2 and the Eric 3.7.0 IDE on Ubuntu 5.10. Anybody know what to do? -- /usr/bin/byte -- http://mail.python.org/mailman/listinfo/python-list
Re: xml.sax problem: getting parse() to read a string
Fredrik Lundh wrote: > if you want to parse a string, use xml.sax.parseString instead of > xml.sax.parse. > > My function has changed to the following (parseString call instead of parse): def parseMessage(self, message): #create a XML parser parser = make_parser() #create an instance of our handler class #generic, prints out to screen on all events dh = docHandler() #tell parser to use our handler parser.setContentHandler(dh) parser.parseString(message) return I am getting the following error. File "acmtest.py", line 205, in parseMessage parser.parseString(message) AttributeError: ExpatParser instance has no attribute 'parseString' Am I simply missing that library here? Or am I calling it incorrectly? My import line reads as follows (but I am not sure how to explictly make sure I have this library) import socket, select, os, sys, traceback, re from xml.sax import make_parser, parseString from xml.sax.handler import ContentHandler -- lucas -- http://mail.python.org/mailman/listinfo/python-list
ConfigParser, no attribute
Hello, I'm not sure exactly what i'm doing wrong here. I asked around on IRC and i was told the code is correct. The purpose of Settings() is that whenever Settings() or any of its methods are called. It should pick up the latest settings from file instead of returning what was in the buffer. This allow other scripts to change the value and my program and pick these changes up. Everything else should work exact same as ConfigParser(). - class Settings(ConfigParser.SafeConfigParser): def __init__(self): self.filename = os.path.join(xchat.get_info('xchatdir'), 'nxscript', 'nxscript.conf') try: config_file = file(self.filename, 'r') self.readfp(config_file, self.filename) if self.sections() == []: self.add_section('Global') if self.has_section('Global'): self.set('Global', 'ProtectME', 'false') config_file.close() except IOError: nx.sysmsg('Configuration file not found') def update_file(self): try: config_file = file(self.filename, 'w') self.write(config_file) except IOError: nx.sysmsg('Could not write to configuration file') - SAMPLE CODE (what i want to able to do): setting = Settings() if setting.get('Global', 'ProtectME'): print 'protection enabled' - ERRORS: File "/home/nexu/.xchat2/nxscript/nx.py", line 43, in ? setting = Settings() File "/home/nexu/.xchat2/nxscript/nx.py", line 24, in __init__ self.readfp(config_file, self.filename) File "/usr/lib/python2.4/ConfigParser.py", line 286, in readfp self._read(fp, filename) File "/usr/lib/python2.4/ConfigParser.py", line 451, in _read if sectname in self._sections: AttributeError: Settings instance has no attribute '_sections' -- http://mail.python.org/mailman/listinfo/python-list
Re: Concatenating dictionary values and keys, and further operations
Gerard Flanagan wrote: > Girish Sahani wrote: > > I wrote the following code to concatenate every 2 keys of a dictionary and > > their corresponding values. > > e.g if i have tiDict1 = tiDict1 = {'a':[1,2],'b':[3,4,5]} i should get > > tiDict2={'ab':[1,2][3,4,5]} and similarly for dicts with larger no. of > > features. > > Now i want to check each pair to see if they are connected...element of > > this pair will be one from the first list and one from the seconde.g > > for 'ab' i want to check if 1 and 3 are connected,then 1 and 4,then 1 and > > 5,then 2 and 3,then 2 and 4,then 2 and 5. > > The information of this connected thing is in a text file as follows: > > 1,'a',2,'b' > > 3,'a',5,'a' > > 3,'a',6,'a' > > 3,'a',7,'b' > > 8,'a',7,'b' > > . > > . > > This means 1(type 'a') and 2(type 'b') are connected,3 and 5 are connected > > and so on. > > I am not able to figure out how to do this.Any pointers would be helpful > > > Girish > > It seems you want the Cartesian product of every pair of lists in the > dictionary, including the product of lists with themselves (but you > don't say why ;-)). > > I'm not sure the following is exactly what you want or if it is very > efficient, but maybe it will start you off. It uses a function > 'xcombine' taken from a recipe in the ASPN cookbook by David > Klaffenbach (2004). > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302478 -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 and HTTP 302
[EMAIL PROTECTED] (John J. Lee) writes: > Laszlo Nagy <[EMAIL PROTECTED]> writes: > [...] > > how can I return the redirection URL? > > I tried to get this information from the exception but I could not. Is > > it possible to read it from the openerdirector? > > Any suggestions? > > > > > > try: > >self.post_multipart( > > url, > > [('uploadType','Inventory')], > > [('uploadFileName','inv.txt',fdata)] > > ) > > except urllib2.HTTPError, e: > > if e.code == 302: > > return "I would like to get the URL to be redirected > > to" > > else: > > raise > > redirected_url = e.geturl() Sorry, didn't read that properly. If your OpenerDirector instance has an HTTPRedirectHandler, you should be able to get the final redirected URL the way I said (using .geturl()). If it doesn't (which I assume is true in your case -- why else would you be checking for a 302 status), well, you just have to do exactly the same thing that HTTPRedirectHandler does :-) Use the source luke. John -- http://mail.python.org/mailman/listinfo/python-list
Re: Concatenating dictionary values and keys, and further operations
Girish Sahani wrote: > I wrote the following code to concatenate every 2 keys of a dictionary and > their corresponding values. > e.g if i have tiDict1 = tiDict1 = {'a':[1,2],'b':[3,4,5]} i should get > tiDict2={'ab':[1,2][3,4,5]} and similarly for dicts with larger no. of > features. > Now i want to check each pair to see if they are connected...element of > this pair will be one from the first list and one from the seconde.g > for 'ab' i want to check if 1 and 3 are connected,then 1 and 4,then 1 and > 5,then 2 and 3,then 2 and 4,then 2 and 5. > The information of this connected thing is in a text file as follows: > 1,'a',2,'b' > 3,'a',5,'a' > 3,'a',6,'a' > 3,'a',7,'b' > 8,'a',7,'b' > . > . > This means 1(type 'a') and 2(type 'b') are connected,3 and 5 are connected > and so on. > I am not able to figure out how to do this.Any pointers would be helpful Girish It seems you want the Cartesian product of every pair of lists in the dictionary, including the product of lists with themselves (but you don't say why ;-)). I'm not sure the following is exactly what you want or if it is very efficient, but maybe it will start you off. It uses a function 'xcombine' taken from a recipe in the ASPN cookbook by David Klaffenbach (2004). (It should give every possibility, which you then check in your file) Gerard - def nkRange(n,k): m = n - k + 1 indexer = range(0, k) vector = range(1, k+1) last = range(m, n+1) yield vector while vector != last: high_value = -1 high_index = -1 for i in indexer: val = vector[i] if val > high_value and val < m + i: high_value = val high_index = i for j in range(k - high_index): vector[j+high_index] = high_value + j + 1 yield vector def kSubsets( alist, k ): n = len(alist) for vector in nkRange(n, k): ret = [] for i in vector: ret.append( alist[i-1] ) yield ret data = { 'a': [1,2], 'b': [3,4,5], 'c': [1,4,7] } pairs = list( kSubsets(data.keys(),2) ) + [ [k,k] for k in data.iterkeys() ] print pairs for s in pairs: for t in xcombine( data[s[0]], data[s[1]] ): print "%s,'%s',%s,'%s'" % ( t[0], s[0], t[1], s[1] ) - 1,'a',1,'c' 1,'a',4,'c' 1,'a',7,'c' 2,'a',1,'c' 2,'a',4,'c' 2,'a',7,'c' 1,'a',3,'b' 1,'a',4,'b' 1,'a',5,'b' 2,'a',3,'b' 2,'a',4,'b' 2,'a',5,'b' 1,'c',3,'b' 1,'c',4,'b' 1,'c',5,'b' 4,'c',3,'b' 4,'c',4,'b' 4,'c',5,'b' 7,'c',3,'b' 7,'c',4,'b' 7,'c',5,'b' 1,'a',1,'a' 1,'a',2,'a' 2,'a',1,'a' 2,'a',2,'a' 1,'c',1,'c' 1,'c',4,'c' 1,'c',7,'c' 4,'c',1,'c' 4,'c',4,'c' 4,'c',7,'c' 7,'c',1,'c' 7,'c',4,'c' 7,'c',7,'c' 3,'b',3,'b' 3,'b',4,'b' 3,'b',5,'b' 4,'b',3,'b' 4,'b',4,'b' 4,'b',5,'b' 5,'b',3,'b' 5,'b',4,'b' 5,'b',5,'b' -- http://mail.python.org/mailman/listinfo/python-list
Re: [twisted] PyOpenSSL and PyCrypto are outdated!
"Mike Meng" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I'm learning Twisted and downloaded pyOpenSSL and pycrypto win32 > installer on http://twisted.sourceforge.net/contrib/ . But I find the > lastest version are for Python 2.3. I try to rebuild pyOpenSSL from > source, but get lots of compile errors. Are these two packages > obsolated? Where can I find updated version? Did you try Google? This question has been asked before. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add few pictures into one
Lad wrote: > Steve Holden wrote: > >>Lad wrote: >> >>>K.S.Sreeram wrote: >>> >>> Lad wrote: >Hello , >is it possible to add( with PYTHON language) several image files into >one? Google for 'Python Imaging Library'... Regards Sreeram >>> >>>Thank you for your reply. >>>I was thinking about this: >>>to open each image file in binary mode , read it and write into the >>>result image file? >>>Is that possible? >>>Regards, >>>L >>> >> >>Of course, but what you haven't said yet is how you want the resulting >>image file to behave. Do you want it to contain tiled copies of the >>original images, or be an animation with each frame being one of the >>original images, or something else I haven't thought of. >> >>We aren't mind readers here. >> >>though-some-regulars-get-close-ly y'rs - steve >>-- > > Steve > Thank you for your reply > All that I want is this: > I download ( via Python) some pictures from internet and I want to add > all these pictures into one =one file/ > So far, I managed to download pictures but I do not know how to add i > them nto one file. > How can I do that? > Thank you for reply and help > L. > Zip file? Image file? "Add all these pictures into one file" isn't (fro me) a sufficient specification. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: how not to run out of memory in cursor.execute
amberite wrote: > [EMAIL PROTECTED] wrote: > >>I am using cx_Oracle and MySQLdb to pull a lot of data from some tables >>and I find that the cursor.execute method uses a lot of memory that >>never gets garbage collected. Using fetchmany instead of fetchall does >>not seem to make any difference, since it's the execute that uses >>memory. Breaking the query down to build lots of small tables doesn't >>help, since execute doesn't give its memory back, after reading enough >>small tables execute returns a memory error. What is the trick to get >>memory back from execute in cx_Oracle and MySQLdb? > > > cx_Oracle and MySQLdb must be handled differently, due to the fact that > MySQL does not actually have cursors (MySQLdb fakes them for you). > > To handle large resultsets efficiently in cx_Oracle simply use the > cursor iteration idiom: > > for row in cursor: > # do stuff with the row > > cx_Oracle takes care of the fetching for you, and your memory usage > should remain fairly constant when using this idiom. > > To handle large resultsets in MySQLdb, you have to resort to multiple > queries: > > l = 1000 > o = 0 > > cursor.execute('SELECT foo FROM Bar LIMIT %d OFFSET %d', (l, o)) > rows = cursor.fetchall() > while len(rows) > 0: > # process the fetched rows > o += l > cursor.execute('SELECT foo FROM Bar LIMIT %d OFFSET %d', (l, o)) > rows = cursor.fetchall() > > cursor.close() > > As you can see, the MySQLdb version is more involved, due to the lack > of real cursor support in the MySQL database. Any database with good > cursor support will likely have good cursor iteration support in the > corresponding DBAPI driver. > > Hope this helps, > > L. Daniel Burr > The MySQLdb solution you give is way more complicated than it needs to be, thereby skewing your opinion towards cx_Oracle unnecessarily. Look up the .fetchmany() method of cursors in the DB API. There is only any need to execute a single query no matter how large the result set: you simply need to keep calling .fetchmany(N) (where N is whatever you've decided by testing is your optimum chunk size) until it returns less than N rows, at which point you have exhausted the query. It's very little more effort to wrap this all up as a generator that effectively allows you to use the same solution as you quote for cx_Oracle. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: Installation Problem
Fredrik Lundh wrote: Marshall Dudley wrote: > That is what I did originally, downloaded the latest version from the main > python site. I compiled by the README file instructions, and I compiled by the > instructions on the python url which are different, but both gave identical > results, compiles fine, runs fine from the directory I compiled in, but will > error out when I move the executible code to and run it from the /usr/local/bin > or the /usr/local directory. deep sigh. alright, one more attempt: DO NOT copy any binaries yourself, DO NOT use any bogus FreeBSD source distribution, DO NOT download 2.2.2 if you need Python 2.3 or newer, DO NOT type random commands into the shell when logged in as root. etc. just follow these instructions: 1) go fetch a the latest source code kit from python.org. I recommend getting Python-2.4.3.tgz: $ wget http://www.python.org/ftp/python/2.4.3/Python-2.4.3.tgz OK, did that again. 2) unpack the file to a local temporary directory $ tar xvfz Python-2.4.3.tar.gz $ cd Python-2.4.3 did that again. 3) in that directory, type the following commands: $ ./configure $ make $ ./python OK, did that, got: Python 2.4.3 (#2, Jun 5 2006, 11:15:03) [GCC 2.95.4 20020320 [FreeBSD]] on freebsd4 Type "help", "copyright", "credits" or "license" for more information. >>> 4) verify that the ./python command prints the following: Python 2.4.3 [followed by some number, and today's date] Type "help", "copyright", "credits" or "license" ... >>> 5) press control-D to leave the interpreter Ok, did that. 6) login as root, and type # make install OK, did that again. (or use sudo, or whatever mechanism you usually do to run a command as root) 7) log out from root. that's it. python is now installed as "/usr/local/bin/python", *and* as "/usr/local/bin/python2.4". support libraries and other files are installed under /usr/local/lib/python2.4 and /usr/local/include/python2.4. OK, that is exactly what I had done previously, but this time there IS a copy of python in the /usr/local/bin directory, and this time it DOES work. Don't know why the previous times it put in the /usr/local/bin/pydoc, /usr/local/bin/idle and /usr/local/bin/smtpd.py files, but not the python executable one. Thanks, Marshall -- http://mail.python.org/mailman/listinfo/python-list
Re: Large Dictionaries
[Jim Segrave] > Actually, presorted lists are not a bad case for heapsort - it's quite > immune to any existing order or lack thereof, Write a heapsort and time it. It's not a difference in O() behavior, but more memory movement is required for a sorted list because transforming the list into a max-heap at the start requires shuffling the largest elements from the end of the list to its start. Initially reverse-sorted is a "good case" for heapsort in the same sense (because the list is already a max-heap then; initially sorted is as far from being a max-heap as is possible). "good" and "bad" are both O(N log N) here, though. BTW, most people have never heard of Smoothsort, which was Dijkstra's excruciating attempt to make heapsort exploit pre-existing order: http://www.cs.utexas.edu/users/EWD/ewd07xx/EWD796.PDF That's one of a hundred algorithms I rejected for Python ;-) > whereas some other sorts, quicksort being a prime example, require > great care to avoid pathological cases. Indeed, Python gave up on quicksort for that reason. While the samplesort hybrid that came between quicksort and the current sort also had theoretical O(N**2) worst-case behavior, it was exceedingly difficult to create such an input, and (unlike as for every quicksort variant Python tried) no real-life case of undue sloth was ever reported against it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Expanding Search to Subfolders
On 2006-06-05, PipedreamerGrey <[EMAIL PROTECTED]> wrote: Just in case you really are trying to accomplish something other than learn Python, there are far easier ways to do these tasks: > This is the beginning of a script that I wrote to open all the > text files in a single directory, then process the data in the > text files line by line into a single index file. #!/bin/bash cat *.txt >outputfile > I'm now trying to the program to process all the text files in > subdirectories, so that I don't have to run the script more > than once. #!/bin/bash cat `find . -name '*.txt'` >outputfile -- Grant Edwards grante Yow! An INK-LING? Sure -- at TAKE one!! Did you BUY any visi.comCOMMUNIST UNIFORMS?? -- http://mail.python.org/mailman/listinfo/python-list
Re: how not to run out of memory in cursor.execute
[EMAIL PROTECTED] wrote: > I am using cx_Oracle and MySQLdb to pull a lot of data from some tables > and I find that the cursor.execute method uses a lot of memory that > never gets garbage collected. Using fetchmany instead of fetchall does > not seem to make any difference, since it's the execute that uses > memory. Breaking the query down to build lots of small tables doesn't > help, since execute doesn't give its memory back, after reading enough > small tables execute returns a memory error. What is the trick to get > memory back from execute in cx_Oracle and MySQLdb? cx_Oracle and MySQLdb must be handled differently, due to the fact that MySQL does not actually have cursors (MySQLdb fakes them for you). To handle large resultsets efficiently in cx_Oracle simply use the cursor iteration idiom: for row in cursor: # do stuff with the row cx_Oracle takes care of the fetching for you, and your memory usage should remain fairly constant when using this idiom. To handle large resultsets in MySQLdb, you have to resort to multiple queries: l = 1000 o = 0 cursor.execute('SELECT foo FROM Bar LIMIT %d OFFSET %d', (l, o)) rows = cursor.fetchall() while len(rows) > 0: # process the fetched rows o += l cursor.execute('SELECT foo FROM Bar LIMIT %d OFFSET %d', (l, o)) rows = cursor.fetchall() cursor.close() As you can see, the MySQLdb version is more involved, due to the lack of real cursor support in the MySQL database. Any database with good cursor support will likely have good cursor iteration support in the corresponding DBAPI driver. Hope this helps, L. Daniel Burr -- http://mail.python.org/mailman/listinfo/python-list
Re: is it possible to find which process dumped core
Steve Holden wrote: > su wrote: >> to find which process dumped core at the promt we give >> >> $ file core.28424 >> >> core.28424: ELF 32-bit LSB core file of 'soffice.bin' (signal 11), >> Intel 80386, version 1 (SYSV), from 'soffice.bin' >> >> from this command we know 'soffice.bin' process dumped core. Now can i >> do the same using python i.e. finding which process dumped core? if so >> how can i do it? >> > Unfortunately, without some debugging, all you are likely to find is > that /usr/bin/python (or some other interpreter executable) dumped core. > > You'd have to poke around inside the core image to find out which file > was being executed when the interpreter failed. I think he didn't want to analyze a Python core dump. su: look into /usr/share/file/magic or whatever it's called on your box to see where "file" looks for the executable name. Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: Expanding Search to Subfolders
On 5 Jun 2006 10:01:06 -0700, PipedreamerGrey <[EMAIL PROTECTED]> wrote: > This is the beginning of a script that I wrote to open all the text > files in a single directory, then process the data in the text files > line by line into a single index file. > > os.chdir("C:\\Python23\\programs\\filetree") > mydir = glob.glob("*.txt") > > index = open("index.rtf", 'w') > > for File in mydir: > count = 1 > file = open(File) > fileContent = file.readlines() > for line in fileContent: > if not line.startswith("\n"): > if count == 1: > > I'm now trying to the program to process all the text files in > subdirectories, so that I don't have to run the script more than once. > I know that the following script will SHOW me the contents of the > subdirectories, but I can't integrate the two: > > def print_tree(tree_root_dir): > def printall(junk, dirpath, namelist): > for name in namelist: > print os.path.join(dirpath, name) > os.path.walk(tree_root_dir, printall, None) > > print_tree("C:\\Python23\\programs\\filetree") > > I've taught myself out of online tutorials, so I think that this is a > matter of a command that I haven't learned rather a matter of logic. > Could someone tell me where to learn more about directory processes or > show me an improved version of my first script snippet? > > Thanks > > -- > http://mail.python.org/mailman/listinfo/python-list > How about something like: import os, stat class DirectoryWalker: # a forward iterator that traverses a directory tree, and # returns the filename def __init__(self, directory): self.stack = [directory] self.files = [] self.index = 0 def __getitem__(self, index): while 1: try: file = self.files[self.index] self.index = self.index + 1 except IndexError: # pop next directory from stack self.directory = self.stack.pop() self.files = os.listdir(self.directory) self.index = 0 else: # got a filename fullname = os.path.join(self.directory, file) if os.path.isdir(fullname) and not os.path.islink(fullname): self.stack.append(fullname) else: return fullname for file, st in DirectoryWalker("."): your function here not tested Lou -- Artificial Intelligence is no match for Natural Stupidity -- http://mail.python.org/mailman/listinfo/python-list
Re: Large Dictionaries
In article <[EMAIL PROTECTED]>, Tim Peters <[EMAIL PROTECTED]> wrote: >[Scott David Daniels] >>> For example, time timsort (Python's internal sort) on pre-sorted >>> data; you'll find it is handled faster than random data. > >O(N) vs O(N log N), in fact. > >[Lawrence D'Oliveiro] >> But isn't that how a reasonable sorting algorithm should behave? Less >> work to do if the data is already sorted? > >For example, the O(N log N) heapsort is unreasonable compared to the >O(N**2) bubblesort by that reasoning (pre-sorted is actually a bad >case for heapsort, but a good case for bubblesort)? O(N log N) >sorting algorithms helped by pre-existing order are uncommon, unless >they do extra work to detect and exploit pre-existing order. Actually, presorted lists are not a bad case for heapsort - it's quite immune to any existing order or lack thereof, whereas some other sorts, quicksort being a prime example, require great care to avoid pathological cases. -- Jim Segrave ([EMAIL PROTECTED]) -- http://mail.python.org/mailman/listinfo/python-list
Re: linking errors with debug build of Python2.4.3
Nonsense! I meant leaving out --enable-shared. On Sunday 04 June 2006 16:17, Martin Wiechert wrote: > You were right, leaving out --with-pydebug did the trick. > > Thanks, Martin > > On Sunday 28 May 2006 03:53, [EMAIL PROTECTED] wrote: > > Martin Wiechert wrote: > > > Hi list, > > > > > > I've created a fresh build of Python 2.4.3 using the following > > > configuration > > > > > > $ ./configure --with-pydebug --prefix=/usr/local/debug --enable-shared > > > --with-fpectl --with-signal-module > > > > > > What did I do wrong? > > > > Try with just: ./configure --with-pydebug --prefix=/usr/local/debug > > > > I think the problem is --enable-shared. I'm not sure what you are > > doing, but you probably don't need the other options. The signal > > module should always be built, I've never even seen the > > --with-signal-module option. :-) > > > > n -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add few pictures into one
Steve Holden wrote: > Lad wrote: > > K.S.Sreeram wrote: > > > >>Lad wrote: > >> > >>>Hello , > >>>is it possible to add( with PYTHON language) several image files into > >>>one? > >> > >>Google for 'Python Imaging Library'... > >> > >>Regards > >>Sreeram > >> > >> > >> > > > > Thank you for your reply. > > I was thinking about this: > > to open each image file in binary mode , read it and write into the > > result image file? > > Is that possible? > > Regards, > > L > > > Of course, but what you haven't said yet is how you want the resulting > image file to behave. Do you want it to contain tiled copies of the > original images, or be an animation with each frame being one of the > original images, or something else I haven't thought of. > > We aren't mind readers here. > > though-some-regulars-get-close-ly y'rs - steve > -- Steve Thank you for your reply All that I want is this: I download ( via Python) some pictures from internet and I want to add all these pictures into one =one file/ So far, I managed to download pictures but I do not know how to add i them nto one file. How can I do that? Thank you for reply and help L. -- http://mail.python.org/mailman/listinfo/python-list
Re: re beginner
WOW! Thanks for all the answers, even those not related to regular expressions tought me some stuff I wasn't aware of. I appreciate it very much. SuperHik wrote: > hi all, > > I'm trying to understand regex for the first time, and it would be very > helpful to get an example. I have an old(er) script with the following > task - takes a string I copy-pasted and wich always has the same format: > > >>> print stuff > Yellow hat2Blue shirt1 > White socks4Green pants1 > Blue bag4Nice perfume3 > Wrist watch7Mobile phone4 > Wireless cord!2Building tools3 > One for the money7Two for the show4 > > >>> stuff > 'Yellow hat\t2\tBlue shirt\t1\nWhite socks\t4\tGreen pants\t1\nBlue > bag\t4\tNice perfume\t3\nWrist watch\t7\tMobile phone\t4\nWireless > cord!\t2\tBuilding tools\t3\nOne for the money\t7\tTwo for the show\t4' > > I want to put items from stuff into a dict like this: > >>> print mydict > {'Wireless cord!': 2, 'Green pants': 1, 'Blue shirt': 1, 'White socks': > 4, 'Mobile phone': 4, 'Two for the show': 4, 'One for the money': 7, > 'Blue bag': 4, 'Wrist watch': 7, 'Nice perfume': 3, 'Yellow hat': 2, > 'Building tools': 3} > > Here's how I did it: > >>> def putindict(items): > ... items = items.replace('\n', '\t') > ... items = items.split('\t') > ... d = {} > ... for x in xrange( len(items) ): > ... if not items[x].isdigit(): d[items[x]] = int(items[x+1]) > ... return d > >>> > >>> mydict = putindict(stuff) > > > I was wondering is there a better way to do it using re module? > perheps even avoiding this for loop? > > thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Storing nothing in a dictionary and passing it to a function
Le Lundi 05 Juin 2006 19:40, Maric Michaud a écrit : > Le Lundi 05 Juin 2006 19:18, [EMAIL PROTECTED] a écrit : > > Any thoughts? > oups wanted to wirte this : In [27]: a, b = (lambda : 'works like this'), (lambda *a : a) In [28]: a(*()) Out[28]: 'works like this' In [29]: b(*()) Out[29]: () -- _ Maric Michaud _ Aristote - www.aristote.info 3 place des tapis 69004 Lyon Tel: +33 426 880 097 -- http://mail.python.org/mailman/listinfo/python-list
Re: Storing nothing in a dictionary and passing it to a function
Le Lundi 05 Juin 2006 19:18, [EMAIL PROTECTED] a écrit : > Any thoughts? In [24]: a, b = (lambda : 'works like this'), (lambda a, b : (a,b)) In [25]: a(*()) Out[25]: 'works like this' In [26]: b(4,3) Out[26]: (4, 3) -- _ Maric Michaud _ Aristote - www.aristote.info 3 place des tapis 69004 Lyon Tel: +33 426 880 097 -- http://mail.python.org/mailman/listinfo/python-list
Re: Storing nothing in a dictionary and passing it to a function
[EMAIL PROTECTED] wrote: > Hi, > > I'm writing a hand-written recursive decent parser for SPICE syntax > parsing. In one case I have one function that handles a bunch of > similar cases (you pass the name and the number of tokens you're > looking for). In another case I have a function that handles a > different set of tokens and so it can't use the same arguments as the > first one, and in fact takes no arguments. However, these functions > are semantically similar and are called from the same place one right > after the other. > > I'd like to have a dictionary (actually a nested dictionary) to call > these functions so I can avoid if-then-elsing everything. Eath > dictionary item has three things in it: the function to be called, a > string to pass to the function (which is also the key to the dict), and > a tuple to pass to the function. In the case of the function with no > arguments, obviously I'd like not to pass anything. > > I'm trying to do this 'functionally' (i guess), by avoiding > if-then-elses and just calling out the functions by accessing them and > their arguments from the dictionary. > > something like this: > alldict = \ > {'pulse': {'func': self.arbtrandef, 'args':(2,5)},\ >'sin' : {'func': self.arbtrandef, 'args':(2,3)},\ >'exp' : {'func': self.arbtrandef, 'args':(2,4)},\ >'pwl' : {'func': self.pwldef, 'args': (None,)},\ > <--- how > do I store "no" arguments? >'sffm' : {'func': self.arbtrandef, 'args':(5,0)}} > > for it in alldict.items(): > name = it[0] > args = (name,) + it[1]['args'] > it[1]['func'](*args) > > So basically this doesn't work. > > Any thoughts? You could omit the 'args' entry completely and test for this in the dispatch: 'pwl' : {'func': self.pwldef},\ for name, params in alldict.items(): try args = (name,) + params['args'] except KeyError: args = () params['func'](*args) Or include the 'name' parameter in the arg list and use an empty tuple for the arg to pwldef: 'exp' : {'func': self.arbtrandef, 'args':('exp', 2,4)},\ 'pwl' : {'func': self.pwldef, 'args': ()},\ for name, params in alldict.items(): params['func'](*args) Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: Starting New Process
try os.spawn() using the os module -- http://mail.python.org/mailman/listinfo/python-list
Re: logging
Hello Vinay, On Sun, Jun 04, 2006 at 05:23:55AM -0700, Vinay Sajip wrote: > It's not propagated to the root logger (or to ancestor loggers in > general) - just to the handlers associated with ancestor loggers. ... > You can set levels on handlers as well as loggers. So if you add a > syslog handler to the root and set its level to CRITICAL, only CRITICAL > messages are sent to syslog. ... > logging.MYCUSTOMLEVEL = 25 > logging.addLevelName(logging.MYCUSTOMLEVEL, "MYCUSTOMLEVEL") Thanks much! With kind regards, Baurzhan. -- http://mail.python.org/mailman/listinfo/python-list
Storing nothing in a dictionary and passing it to a function
Hi, I'm writing a hand-written recursive decent parser for SPICE syntax parsing. In one case I have one function that handles a bunch of similar cases (you pass the name and the number of tokens you're looking for). In another case I have a function that handles a different set of tokens and so it can't use the same arguments as the first one, and in fact takes no arguments. However, these functions are semantically similar and are called from the same place one right after the other. I'd like to have a dictionary (actually a nested dictionary) to call these functions so I can avoid if-then-elsing everything. Eath dictionary item has three things in it: the function to be called, a string to pass to the function (which is also the key to the dict), and a tuple to pass to the function. In the case of the function with no arguments, obviously I'd like not to pass anything. I'm trying to do this 'functionally' (i guess), by avoiding if-then-elses and just calling out the functions by accessing them and their arguments from the dictionary. something like this: alldict = \ {'pulse': {'func': self.arbtrandef, 'args':(2,5)},\ 'sin' : {'func': self.arbtrandef, 'args':(2,3)},\ 'exp' : {'func': self.arbtrandef, 'args':(2,4)},\ 'pwl' : {'func': self.pwldef, 'args': (None,)},\ <--- how do I store "no" arguments? 'sffm' : {'func': self.arbtrandef, 'args':(5,0)}} for it in alldict.items(): name = it[0] args = (name,) + it[1]['args'] it[1]['func'](*args) So basically this doesn't work. I am either trying to pass a tuple of (name, None,) to a function (pwldef) that doesn't take any arguments, or I'm trying to pass None itself, which also doesn't work. I could try changing pwldef to take 3 arguments and then just throw them away, but that's cheesy. It almost seems like in 'args' there should be a little function that creates an argument. I tried using a lambda in another situation to "do" something (an assignment) rather than "return" something, but it didn't work. Any thoughts? thanks ms -- http://mail.python.org/mailman/listinfo/python-list
Expanding Search to Subfolders
This is the beginning of a script that I wrote to open all the text files in a single directory, then process the data in the text files line by line into a single index file. os.chdir("C:\\Python23\\programs\\filetree") mydir = glob.glob("*.txt") index = open("index.rtf", 'w') for File in mydir: count = 1 file = open(File) fileContent = file.readlines() for line in fileContent: if not line.startswith("\n"): if count == 1: I'm now trying to the program to process all the text files in subdirectories, so that I don't have to run the script more than once. I know that the following script will SHOW me the contents of the subdirectories, but I can't integrate the two: def print_tree(tree_root_dir): def printall(junk, dirpath, namelist): for name in namelist: print os.path.join(dirpath, name) os.path.walk(tree_root_dir, printall, None) print_tree("C:\\Python23\\programs\\filetree") I've taught myself out of online tutorials, so I think that this is a matter of a command that I haven't learned rather a matter of logic. Could someone tell me where to learn more about directory processes or show me an improved version of my first script snippet? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: reordering elements of a list
Thanks all for your help! -- http://mail.python.org/mailman/listinfo/python-list
Re: xml.sax problem: getting parse() to read a string
[EMAIL PROTECTED] wrote: > So in recap, it looks like it is trying to take my string argument as a > file handler. How can I get around this? if you want to parse a string, use xml.sax.parseString instead of xml.sax.parse. -- http://mail.python.org/mailman/listinfo/python-list
Re: Installation Problem
Marshall Dudley wrote: > That is what I did originally, downloaded the latest version from the main > python site. I compiled by the README file instructions, and I compiled by > the > instructions on the python url which are different, but both gave identical > results, compiles fine, runs fine from the directory I compiled in, but will > error out when I move the executible code to and run it from the > /usr/local/bin > or the /usr/local directory. deep sigh. alright, one more attempt: DO NOT copy any binaries yourself, DO NOT use any bogus FreeBSD source distribution, DO NOT download 2.2.2 if you need Python 2.3 or newer, DO NOT type random commands into the shell when logged in as root. etc. just follow these instructions: 1) go fetch a the latest source code kit from python.org. I recommend getting Python-2.4.3.tgz: $ wget http://www.python.org/ftp/python/2.4.3/Python-2.4.3.tgz 2) unpack the file to a local temporary directory $ tar xvfz Python-2.4.3.tar.gz $ cd Python-2.4.3 3) in that directory, type the following commands: $ ./configure $ make $ ./python 4) verify that the ./python command prints the following: Python 2.4.3 [followed by some number, and today's date] Type "help", "copyright", "credits" or "license" ... >>> 5) press control-D to leave the interpreter 6) login as root, and type # make install (or use sudo, or whatever mechanism you usually do to run a command as root) 7) log out from root. that's it. python is now installed as "/usr/local/bin/python", *and* as "/usr/local/bin/python2.4". support libraries and other files are installed under /usr/local/lib/python2.4 and /usr/local/include/python2.4. -- http://mail.python.org/mailman/listinfo/python-list
Re: Concatenating dictionary values and keys, and further operations
Girish Sahani <[EMAIL PROTECTED]>: > I wrote the following code to concatenate every 2 keys of a dictionary and > their corresponding values. > e.g if i have tiDict1 = tiDict1 = {'a':[1,2],'b':[3,4,5]} i should get > tiDict2={'ab':[1,2][3,4,5]} and similarly for dicts with larger no. of > features. Note that dictionary keys are not ordered, so--if I understand your requirement correctly--it could also result in {'ba': [3, 4, 5, 1, 2]}. > Now i want to check each pair to see if they are connected...element of > this pair will be one from the first list and one from the seconde.g > for 'ab' i want to check if 1 and 3 are connected,then 1 and 4,then 1 and > 5,then 2 and 3,then 2 and 4,then 2 and 5. According to this, I think that you shouldn't concatenate the lists, but keep them apart instead. > The information of this connected thing is in a text file as follows: > 1,'a',2,'b' > 3,'a',5,'a' > 3,'a',6,'a' > 3,'a',7,'b' > 8,'a',7,'b' > . > This means 1(type 'a') and 2(type 'b') are connected,3 and 5 are connected > and so on. > I am not able to figure out how to do this.Any pointers would be helpful I don't understand very well what you want to do. Could you explain it more clearly, with an example? -- Roberto Bonvallet -- http://mail.python.org/mailman/listinfo/python-list
xml.sax problem: getting parse() to read a string
Hey all, I recently came across the xml.sax libraries and am trying to use them. I am currently making a string variable, and am attempting to pass it into a parser instance as follows: def parseMessage(self, message): #create a XML parser parser = make_parser() #create an instance of our handler class #generic, prints out to screen on all events dh = docHandler() #tell parser to use our handler parser.setContentHandler(dh) #start it going, will trigger on events as defined in the docHandler class parser.parse(message) return "message" is the following text: - - - timestamp - asdasd asdasds --- This is dying with the following errors. File "./python/lib/python2.4/urllib.py", line 77, in urlopen return opener.open(url) File "./python/lib/python2.4/urllib.py", line 180, in open return getattr(self, name)(url) File "./python/lib/python2.4/urllib.py", line 409, in open_file return self.open_local_file(url) File "./python/lib/python2.4/urllib.py", line 419, in open_local_file raise IOError(e.errno, e.strerror, e.filename) IOError: [Errno 2] No such file or directory: '?xml version="1.0" ?>\n- \n - \n timestamp\n - \n asdasd\n asdasds\n \n\n http://mail.python.org/mailman/listinfo/python-list
[twisted] PyOpenSSL and PyCrypto are outdated!
Hi all, I'm learning Twisted and downloaded pyOpenSSL and pycrypto win32 installer on http://twisted.sourceforge.net/contrib/ . But I find the lastest version are for Python 2.3. I try to rebuild pyOpenSSL from source, but get lots of compile errors. Are these two packages obsolated? Where can I find updated version? Thank you in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: strategy pattern and non-public virtual functions
Le Lundi 05 Juin 2006 16:07, [EMAIL PROTECTED] a écrit : > class Base { > public: > void f() { this->f_(); } > private: > virtual void f_() = 0; > }; > > class Derived : public Base { > private: > void f_() { // Do something } > }; > > int main() { > Derived d; > d.f(); > } This is just polymorphism, not strategy pattern, and I would expect f_ to be protected here not private. You want to ensure derived class will use a given method in the Base class, this could be done explicit with a good naming convention as Duncan said, but here is a strategy pattern to ensure a sanity check for example : class strategyBase(object) : def __call__(self, *sa) : raise NotImplementedError('abstract class') class InputProcessor(object) : def sanitize(self, *a) : return a def f(self, *a) : sa = self.sanitize(*a) return self.strategy(*sa) def __setStrategy(self, strat) : if not isinstance(strat, strategyBase) : raise ValueError("strat must be of type strategyBase") self.__strat = strat strategy = property(fget=lambda s : s.__strat, fset=__setStrategy) The main purpose of this is to define a common API for all Strategies, and this is really useful if you intend to manage many of them. -- _ Maric Michaud _ Aristote - www.aristote.info 3 place des tapis 69004 Lyon Tel: +33 426 880 097 -- http://mail.python.org/mailman/listinfo/python-list
Re: Installation Problem
Fredrik Lundh wrote: > Marshall Dudley wrote: > > > Is it not possible to install the latest version of python on my FreeBSD > > system? Upgrading the FreeBSD is not an option since this is a production > > system and everything else is working fine. > > that's really a FreeBSD question, isn't it? > > > You are using: 2.2.2 (#1, Jun 4 2006, 16:29:13) > > Python 2.2.2 was originally released in 2002, but your copy was built > yesterday? did the FreeBSD source kit you got really contain a four > year old release? heck, it's not even the 2.2 release in the 2.2 > series, and there's been two major releases since then. No, there was no copy on the system. When I did the make the last time as directed in the previous message, it downloaded it from the python site, then compiled and installed it. The 2.2.2 release is what it downloaded. > > > are you sure you cannot get a *prebuilt* newer version from some FreeBSD > repository? I did compile a new copy originally, and it worked fine in the directory that I compiled it in, but when moved to the /usr/local/bin directory where it should have installed, it complains that it cannot find it's library. It may just be a matter of what directory I should put the sources into and compile from, but I can find nowhere that this information is provided, everything I see indicates I can compile it in any directory. > > > or if that's not possible, use the *standard* python.org source kit? > after all, it's known to build and install on virtually any modern Unix > or Unix-like system (and most non-Unix systems too), and you're free to > install it everywhere you want (and the default on Unix is /usr/local, > so you don't even have to read the README; just make sure you use the > real thing, instead of some botched FreeBSD-specific source kit). That is what I did originally, downloaded the latest version from the main python site. I compiled by the README file instructions, and I compiled by the instructions on the python url which are different, but both gave identical results, compiles fine, runs fine from the directory I compiled in, but will error out when I move the executible code to and run it from the /usr/local/bin or the /usr/local directory. Marshall > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Starting New Process
Sorry to bring it back up, but is there a way to spawn the process without Twisted? -- http://mail.python.org/mailman/listinfo/python-list